#ifndef __VTOR_BUFFER_H
#define __VTOR_BUFFER_H

#ifdef __cplusplus
extern "C" {
#endif

#include "vtor_elec_module_config.h"


#ifdef __VTOR_BUFFER__

typedef struct
{
	uint8_t* buf;
	uint16_t maxLen;
	uint16_t pushIdx;
	uint16_t popIdx;
}VtorSingleBuffer;

typedef struct
{
	uint8_t* bufArray;
	
	uint8_t* inBuf; // 直接操作的指针
	uint8_t* outBuf;
	uint16_t inBufLen;
	uint16_t maxBufLen;
	uint16_t bufCnt; // buf的个数
}VtorMultiBuffer;



void VtorSingleBuffer_OverflowCallback(VtorSingleBuffer* buf);
void VtorSingleBuffer_Push(VtorSingleBuffer* buf, uint8_t* inBuf, int16_t inLen);
int16_t VtorSingleBuffer_Pop(VtorSingleBuffer* buf, uint8_t* outBuf, int16_t expOutLen);

void VtorMultiBuffer_OverflowCallback(VtorMultiBuffer* buf);
void VtorMultiBuffer_SwitchInBuf(VtorMultiBuffer* buf);
void VtorMultiBuffer_SwitchOutBuf(VtorMultiBuffer* buf);
void VtorMultiBuffer_Push(VtorMultiBuffer* buf, uint8_t ch);


void VtorMultiBuffer_SwitchInBufCallback(VtorMultiBuffer* buf);
void VtorMultiBuffer_SwitchOutBufCallback(VtorMultiBuffer* buf);
uint8_t VtorMultiBuffer_CheckSwitchInBuf(VtorMultiBuffer* buf);

// singlebuffer和multibuffer在一起初始化
void VtorBuffer_Init(void);
#endif // __VTOR_BUFFER__

#ifdef __cplusplus
}
#endif

#endif

